﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Liwey.Common;
using System.Reflection;


namespace Liwey.SGCC
{
    [ObfuscationAttribute(Exclude = true, ApplyToMembers = true, StripAfterObfuscation = false)]
    public class Config
    {
        public DBServer db = new DBServer();
        public ACServer acs = new ACServer();
        public List<Park> parks = new List<Park>();
        public DateTime updated;

        [ObfuscationAttribute(Exclude = true, ApplyToMembers = true, StripAfterObfuscation = false)]
        public class DBServer
        {
            public string server = ".";
            public string database = "AccessData";
            public string username;
            public string password;

            [JsonIgnore]
            public string ConnectionString{
                get{
                    if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
                        return string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True;Persist Security Info=True", server, database);
                    else
                        return string.Format("Data Source = {0};Initial Catalog = {1};User Id = {2};Password = {3};", server, database, username, password);
                }
            }
        }

        [ObfuscationAttribute(Exclude = true, ApplyToMembers = true, StripAfterObfuscation = false)]
        public class ACServer
        {
            public string host = "localhost";
            public int port = 60006;
            public string username = "abc";
            public string password = "123";
        }

        [ObfuscationAttribute(Exclude = true, ApplyToMembers = true, StripAfterObfuscation = false)]
        public class Park
        {
            public string name { get; set; }
            public int places;
            public int balance;

            public List<int> leds = new List<int>();
            public List<string> controllers = new List<string>();

            [NonSerialized]
            public List<string> doors = new List<string>();
            [NonSerialized]
            public List<LED> LEDs = new List<LED>();   
        }
    }
}
